#include "bstim32_timing.h"
#include "user_gpio.h"

extern uint32_t bstim_cnt;
extern uint8_t Period_Green_led;
extern uint8_t Period_Red_led;
extern uint8_t Alarm_Status;

void BSTIM32_Start()
{
    
    FL_BSTIM32_Enable(BSTIM32);
}

void BSTIM32_Loop()
{
  
}

void BSTIM_IRQHandler()
{
    if(FL_BSTIM32_IsEnabledIT_Update(BSTIM32) && FL_BSTIM32_IsActiveFlag_Update(BSTIM32))
    {
        FL_BSTIM32_ClearFlag_Update(BSTIM32);

        
        
			bstim_cnt++;
			if(Alarm_Status==1)
			{
				if((bstim_cnt%(Period_Red_led<<1))<Period_Red_led)
				{
					LED2_ON;
					LED3_ON;
				}
				else
				{
					LED2_OFF;
					LED3_OFF;
				}	
			}
		else
		{
			LED2_OFF;
			LED3_OFF;	
			if((bstim_cnt%(Period_Green_led<<1))<Period_Green_led)
					LED1_ON;
			else
					LED1_OFF;
		}
   }
		
}
